package com.ayoka.menu;

import android.content.Context;
import android.support.v4.view.ActionProvider;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.ayoka.R;
import com.jcp.baselibrary.utils.UIUtils;

/**
 * @ProjectName: ayoka5.
 * @ClassName: BadgeActionProvider.
 * @Description: .
 * @Author: jincp.
 * @CreateDate: 2019/3/28 10:09.
 */

public class CourseEstimateActionProvider extends ActionProvider {

    // 用来记录是哪个View的点击，这样外部可以用一个Listener接受多个menu的点击。
    private View.OnClickListener onClickListener;

    public CourseEstimateActionProvider(Context context) {
        super(context);
    }

    @Override
    public View onCreateActionView() {
        int height = (int) UIUtils.getDimensionPixelSize(R.dimen.action_bar_height);
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, height);
        View view = LayoutInflater.from(getContext()).inflate(R.layout.menu_action_course_estimate, null, false);
        view.setLayoutParams(layoutParams);
        TextView tvEstimate = (TextView) view.findViewById(R.id.tv_estimate);
        tvEstimate.setOnClickListener(onClickListener);
        return view;
    }

    // 外部设置监听。
    public void setOnClickListener(View.OnClickListener onClickListener) {
        this.onClickListener = onClickListener;
    }
}
